package org.wyz.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wyz.domain.Role;
import org.wyz.domain.User;
import org.wyz.mapper.RolesMapper;
import org.wyz.mapper.UserMapper;

import java.util.List;

/**
 * Created by wyz on 2018/1/22.
 */
@RestController
@EnableAutoConfiguration
public class HelloController {

    @Autowired
    UserMapper userMapper;
    @Autowired
    RolesMapper rolesMapper;


    @RequestMapping("/")
    String home() {
        return "Hello World!";
    }

    @RequestMapping("/userid")
    User getUserById() {
        return userMapper.getUserById(6L);
    }

    @RequestMapping("/userlist")
    List<User> getUserList() {
        return userMapper.getAllUesrs();
    }

    @RequestMapping("/userroleList")
    List<User> getUserByNickname(String nickname) {
        return userMapper.getUserByNickname(null);
    }

    @RequestMapping("/role")
    List<Role> getRoleList(Long uid) {

        uid = 7L;

        return rolesMapper.getRolesByUid(uid);
    }

    @RequestMapping("/roles")
    List<Role> getRoleList() {

        return userMapper.getAllRole();
    }

}
